<?php
declare (strict_types = 1);

namespace app\common\command;

use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\facade\Cache;
use app\common\service\Redis as RedisServer;
class Redis extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('redis')
            ->addArgument('order_id', Argument::OPTIONAL, "订单id")
            ->addArgument('group_id', Argument::OPTIONAL, "拼团id")
            ->addOption('city', null, Option::VALUE_REQUIRED, 'city name')
            ->setDescription('the del command');
    }

    protected function execute(Input $input, Output $output)
    {
       /* $name = trim($input->getArgument('order_id'));
        $name = $name ?: 'thinkphp';

        \swoole\timer::after(5000,function(){
            echo "3000后执行 \n";
            //$output->writeln($name);
        });*/

        $this->setkey();
        // 指令输出
        //$output->writeln($name);
    }

    public function setKey(){
        $redis = RedisServer::instance(1);
        //ini_set('default_socket_timeout', -1);
        //$redis = new \Redis();
        //$redis->connect("127.0.0.1", 6379);
        //$redis->auth('baguatan');
        //$redis = Cache::store('redis')->handler()->select(2);
        //$redis->select(1);
        $redis->setex('order1',10,'2017401');
        $redis->setex('order2',35,'2017401');
        $redis->setex('order3',20,'2017401');
    }


}
